<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var search = function(nums, target) {
			    let low = 0, high = nums.length - 1;
			    while (low <= high) {
			        const mid = Math.floor((high - low) / 2) + low;
			        const num = nums[mid];
			        if (num === target) {
			            return mid;
			        } else if (num > target) {
			            high = mid - 1;
			        } else {
			            low = mid + 1;
			        }
			    }
			    return -1;
			};
			console.log(search([-1,0,3,5,9,12],9));
		</script>
	</body>
</html>
